// obsługa klawiatury
var Keys = function(_up, _left, _right, _down, _esc) {

    var up = _up || false;
    var	left = _left || false;
    var	right = _right || false;
    var	down = _down || false;
    var esc = _esc || false;

    // wciśnięcie klawisza strzałki
    var onKeyDown = function(e) {

        var t = this;
        var key = e.keyCode;
        switch (key) {

            case 37:
                t.left = true;
                break;
            case 38:
                t.up = true;
                break;
            case 39:
                t.right = true;
                break;
            case 40:
                t.down = true;
                break;
                
            case 27: //esc
                t.esc = true;

                break;
        }
    };

    // puszczenie klawisza strzałki
    var onKeyUp = function(e) {

        var t = this;
        var key = e.keyCode;

        t.esc = false;

        switch (key) {
            case 37:
                t.left = false;
                break;
            case 38:
                t.up = false;
                break;
            case 39:
                t.right = false;
                break;
            case 40:
                t.down = false;
                break;
        }
    };

    return {
        up: up,
        left: left,
        right: right,
        down: down,
        esc : esc,
        onKeyDown: onKeyDown,
        onKeyUp: onKeyUp
        
    };
};